home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 5 / Gekikoh Dennoh Club Vol. 5 (Japan).7z / Gekikoh Dennoh Club Vol. 5 (Japan) (Track 01).bin / tools / condrv / cond_e12.lzh / src / dumphelp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-23  |  1.0 KB  |  65 lines

  1. /* dumphelp
  2.  *   function: help âtâ@âCâïé≡âoâbâtâ@é╓ô╟é▌ì₧é±é╛Å≤æ╘é╔ì\ɼé╖éΘ
  3.  *   usage: ./dumphelp < text > source
  4.  */
  5.  
  6. #include    <stdio.h>
  7. #include    <string.h>
  8.  
  9. #define    DC_B    "\t\t.dc.b\t"
  10. #define    MAXLEN    96
  11.  
  12. #define    QUOTE_START() ({    \
  13.       if (!in_quote)    \
  14.         {            \
  15.           putchar ('\'');    \
  16.           in_quote = 1;    \
  17.         }            \
  18.     })
  19. #define    QUOTE_END() ({        \
  20.       if (in_quote)        \
  21.         {            \
  22.           printf ("',");    \
  23.           in_quote = 0;    \
  24.         }            \
  25.     })
  26.  
  27. int
  28. main (int argc, char *argv[])
  29. {
  30.   char buf[MAXLEN + 1];
  31.  
  32.   if (argc != 1)
  33.     return 1;
  34.  
  35.   while (fgets (buf, sizeof buf, stdin) && buf[0])
  36.     {
  37.       int len = strlen (buf);
  38.       unsigned char* p;
  39.       int in_quote;
  40.  
  41.       buf[len - 1] = '\0';
  42.       printf (DC_B "%2d,", len);
  43.       for (in_quote = 0, p = buf; *p; p++)
  44.     {
  45.       if (*p == (char)'\'')
  46.         {
  47.           QUOTE_END();
  48.           printf ("%d,", *p);
  49.         }
  50.       else
  51.         {
  52.           QUOTE_START();
  53.           putchar (*p);
  54.         }
  55.     }
  56.       QUOTE_END();
  57.       printf ("CR,%d\n", len);
  58.  
  59.     } /* end while */
  60.  
  61.   return 0;
  62. }
  63.  
  64. /* EOF */
  65.